import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: "/home/dashboard"//首页重定向
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '../views/login/index.vue')
  },
  {//仪表盘的路由和子路径
    path: '/home',
    name: 'home',
    component:layout,
    meta: { title:"首页",icon:"icon-panel",type:"2" },
    children:[
      {
        path:"dashboard",
        name:"dashboard",
        component:()=>import(/* webpackChunkName: "dashboard" */ '../views/dashboard/index.vue'),
        meta: { title:"仪表盘",type:"2" },
      },
      {
        path:"data",
        name:"dashdata",
        component:()=>import(/* webpackChunkName: "data" */ '../views/dashboard/data.vue'),
        meta: { title:"设备数据",type:"2" },
      }
    ]
  },

  {//设备的路由和子路由
    path:"/device",
    name:"device",
    component:layout,
    meta: { title:"设备",icon:"icon-luyouqi",type:"2" },
    children:[
      {
        path:"gateway",
        name:"gateway",
        component:()=>import(/* webpackChunkName: "gateway" */ '../views/device/gateway.vue'),
        meta: { title:"网关",type:"2" },
      },
      {
        path:"grouplist",
        name:"grouplist",
        component:()=>import(/* webpackChunkName: "grouplist" */ '../views/device/grouplist.vue'),
        meta: { title:"设备群组",type:"2" },
      },
      {
        path:"sensorlist",
        name:"sensorlist",
        component:()=>import(/* webpackChunkName: "sensorlist" */ '../views/device/sensorlist.vue'),
        meta: { title:"传感器列表",type:"2" },
      }
    ]
  },
  {//账户的路由和子路由
    path:"/account",
    name:"account",
    component:layout,
    meta: { title:"账号",icon:"icon-account",type:"1" },
    children:[
      {
        path:"addaccount",
        name:"addaccount",
        component:()=>import(/* webpackChunkName: "addaccount" */ '../views/account/addaccount.vue'),
        meta: { title:"添加账号",type:"1" },
      },
      {
        path:"accountList",
        name:"accountList",
        component:()=>import(/* webpackChunkName: "accountList" */ '../views/account/accountList.vue'),
        meta: { title:"账号列表",type:"1" },
      }
    ]
  },
  {//安全的路由和子路由
    path:"/security",
    name:"security",
    component:layout,
    meta: { title:"安全",icon:"icon-anquan",type:"1" },
    children:[
      {
        path:"addsecretKey",
        name:"addsecretKey",
        component:()=>import(/* webpackChunkName: "addsecurityKey" */ '../views/security/addsecretKey.vue'),
        meta: { title:"添加密钥",type:"1" },
      },
      {
        path:"secretKeyList",
        name:"secretKeyList",
        component:()=>import(/* webpackChunkName: "secretKeyList" */ '../views/security/secretKeyList.vue'),
        meta: { title:"密钥列表",type:"1" },
      }
    ]
  },
  {//测量的路由和子路由
    path:"/measure",
    name:"measure",
    component:layout,
    meta: { title:"测量类型",icon:"icon-signal",type:"2" },
    children:[
      {
        path:"measureType",
        name:"measureType",
        component:()=>import(/* webpackChunkName: "measureType" */ '../views/measure/measureType.vue'),
        meta: { title:"添加测量类型",type:"2" },
      },
      {
        path:"addmeasure",
        name:"addmeasure",
        component:()=>import(/* webpackChunkName: "addmeasure" */ '../views/measure/addmeasure.vue'),
        meta: { title:"测量类型列表",type:"2" },
      }
    ]
  },
   {//计费的路由和子路由
    path:"/charging",
    name:"charging",
    component:layout,
    meta: { title:"计费",icon:"icon-fyxx",type:"1" },
    children:[
      {
        path:"BilAccount",
        name:"BilAccount",
        component:()=>import(/* webpackChunkName: "BilAccount" */ '../views/charging/BilAccount.vue'),
        meta: { title:"账户信息",type:"1" },
      },
      {
        path:"Recharge",
        name:"Recharge",
        component:()=>import(/* webpackChunkName: "Recharge" */ '../views/charging/Recharge.vue'),
        meta: { title:"充值记录",type:"1" },
      },
      {
        path:"useList",
        name:"useList",
        component:()=>import(/* webpackChunkName: "useList" */ '../views/charging/useList.vue'),
        meta: { title:"使用记录",type:"1" },
      }
    ]
  },
  {
    path: '*',
    name: 'page404',
    component: () => import(/* webpackChunkName: "page404" */ '../views/page404/index.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
